using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Data;
using DTO;

namespace DAO
{
  public static class PhieuphatDAO
    {
      public static bool lapphieuphat(PhieuphatDTO dto)
      {
          string sql = "insert into Phieuphat(MaDG,TenDG,Lydo,Thanhtien)values('" + dto. MaDG + "','" + dto.TenDG + "','" + dto.Lydo + "'," + dto.Thanhtien + ")";
          return DataProvider.ExecuteNonQuery(sql);
      }
      public static int laymasach()
      {
          string sql = "select max(MaPP) from Phieuphat";

          OleDbCommand cmd = new OleDbCommand(sql, DataProvider.ketnoi());
          int maphieu = (int)cmd.ExecuteScalar();
          int maphieumoi = maphieu + 1;
          return maphieumoi;


      }
      public static bool updatephieuphat(PhieuphatDTO dto)
      {
          string sql = "update Phieuphat set MaDG='" + dto.MaDG + "',TenDG='" + dto.TenDG + "',Lydo='" + dto.Lydo + "',Thanhtien=" + dto.Thanhtien + " where MaPP="+dto.MaPP+"";
          return DataProvider.ExecuteNonQuery(sql);
      }
      public static bool xoaPP(PhieuphatDTO dto)
      {
          string sql = "delete from Phieuphat where MaPP=" + dto.MaPP + "";
          return DataProvider.ExecuteNonQuery(sql);
      }
    }
}
